#include <stdio.h>
#include <stdlib.h>

#include "Merge.h"

void visit(void *p)
{
    ElemType *q = (ElemType *)p;
    printf("%d\t",*q);
    return ;
}

int main()
{
    SqList L1,L2,L3;
    int ret,i;
    int arr1[] = {1,3,5,7,9};
    int arr2[] = {1,2,3,6,7};

    ret = InitList(&L1);
    if (ret!=OK)
    {
        printf("List Init failed!\n");
        exit(-1);
    }
    ret = InitList(&L2);
    if (ret!=OK)
    {
        printf("List Init failed!\n");
        exit(-1);
    }
    ret = InitList(&L3);
    if (ret!=OK)
    {
        printf("List Init failed!\n");
        exit(-1);
    }

    for ( i = 0; i < sizeof(arr1)/sizeof(*arr1); i++)
    {
        ret = ListInsert(&L1,i,arr1[i]);
        if(ret != OK)
        {
            printf("ListInsert failed!\n");
            break;
        }
    }

    for ( i = 0; i < sizeof(arr2)/sizeof(*arr2); i++)
    {
        ret = ListInsert(&L2,i,arr2[i]);
        if(ret != OK)
        {
            printf("ListInsert failed!\n");
            break;
        }
    }

    MergeList_2(L1,L2,&L3);

    ListTraverse(L3,visit);    

    exit(0);
}